﻿using YasharEl.Infrastructure.ApplicationModel.Bootstrap.Extensibility;
using System.Diagnostics.Contracts;
using System;

namespace YasharEl.Infrastructure.ApplicationModel.Bootstrap.Configuration.Internals
{
    /// <summary>
    /// Default IHaveConfigurationSectionName
    /// </summary>
    public class HaveConfigurationSectionName : IHaveConfigurationSectionName
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="HaveConfigurationSectionName"/> class.
        /// </summary>
        /// <param name="extension">The extension.</param>
        public HaveConfigurationSectionName(IBootstrappingExtension extension)
        {
            Contract.Requires<ArgumentNullException>(extension != null, "extension could not be null.");

            var namer = extension as IHaveConfigurationSectionName;

            this.SectionName = namer != null
                ? namer.SectionName
                : extension.GetType().Name;
        }

        /// <summary>
        /// Gets the section name.
        /// </summary>
        public string SectionName { get; private set; }
    }
}